#include <iostream>
#include <algorithm>

using namespace std;

const int N = 110;
int a[N];
void solve()
{
    int n; cin >> n;
    for(int i = 1;i <= n;i ++) cin >> a[i];
    sort(a + 1 ,a + 1 + n);
    cout << a[n] - a[1] << endl;
}
int main()
{
    int t; cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}